'****************************************************************************'
'                                                                            '
' Copyright (C) 2010 Muhammad alaa                                           '
'                                                                            '
' This program is free software; you can redistribute it and/or modify       '
' it under the terms of the GNU General Public License as published by       '
' the Free Software Foundation; either version 2 of the License, or          '
' (at your option) any later version.                                        '
'                                                                            '
' This program is distributed in the hope that it will be useful,            '
' but WITHOUT ANY WARRANTY; without even the implied warranty of             '
' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              '
' GNU General Public License for more details.                               '
'                                                                            '
' You should have received a copy of the GNU General Public License along    '
' with this program; if not, write to the Free Software Foundation, Inc.,    '
' 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.                '
'                                                                            '
'****************************************************************************'

Imports SmartVision.HResults

Namespace API

    Public NotInheritable Class OleAPI
        Private Sub New()
        End Sub

        ' OLE Direct API Goes Here
        Public Declare Function CreateDataAdviseHolder Lib "ole32.dll" (<Out()> ByRef ppDAHolder As IOLE.IDataAdviseHolder) As <MarshalAs(UnmanagedType.Error)> Integer
        Public Declare Function CreateDataCache Lib "ole32.dll" (<MarshalAs(UnmanagedType.IUnknown)> ByRef pUnkOuter As Object, ByRef rclsid As Guid, ByRef riid As Guid, <Out(), MarshalAs(UnmanagedType.Interface)> ByRef ppv As Object) As <MarshalAs(UnmanagedType.Error)> Integer
        Public Declare Function CreateFormatEnumerator Lib "URLMON.dll" (ByVal cfmtetc As UInteger, <MarshalAs(UnmanagedType.LPArray)> ByRef rgfmtetc() As FormatETC, <Out()> ByRef ppenumfmtetc As IOLE.IEnumFORMATETC) As <MarshalAs(UnmanagedType.Error)> Integer
        Public Declare Function CreateOleAdviseHolder Lib "ole32.dll" (<Out()> ByRef ppOAHolder As IOLE.IOleAdviseHolder) As <MarshalAs(UnmanagedType.Error)> Integer
        Public Declare Function DoDragDrop Lib "ole32.dll" (ByRef pDataObj As IOLE.IDataObject, ByRef pDropSource As IOLE.IDropSource, ByVal dwOKEffects As DropEffect, ByRef pdwEffect As UInteger) As <MarshalAs(UnmanagedType.Error)> Integer
        Public Declare Function OleCreate Lib "ole32.dll" (ByRef rclsid As Guid, ByRef riid As Guid, ByVal renderopt As OleRender, ByRef pFormatEtc As FormatETC, ByRef pClientSite As OLE.IOleClientSite, ByRef pStg As OLE.IStorage, <Out(), MarshalAs(UnmanagedType.Interface)> ByRef ppvObj As Object) As <MarshalAs(UnmanagedType.Error)> Integer
        Public Declare Function OleCreateDefaultHandler Lib "ole32.dll" (ByRef clsid As Guid, <MarshalAs(UnmanagedType.IUnknown)> ByRef pUnkOuter As Object, ByRef riid As Guid, <Out(), MarshalAs(UnmanagedType.Interface)> ByRef lplpObj As Object) As <MarshalAs(UnmanagedType.Error)> Integer
        Public Declare Function OleCreateEmbeddingHelper Lib "ole32.dll" (ByRef clsid As Guid, <MarshalAs(UnmanagedType.IUnknown)> ByRef pUnkOuter As Object, ByVal flags As UInteger, ByRef pCF As ICOM.IClassFactory, ByRef riid As Guid, <Out(), MarshalAs(UnmanagedType.Interface)> ByRef lplpObj As Object) As <MarshalAs(UnmanagedType.Error)> Integer
        Public Declare Function OleCreateEx Lib "ole32.dll" (ByRef rclsid As Guid, ByRef riid As Guid, ByVal dwFlags As UInteger, ByVal renderopt As OleRender, ByVal cFormats As UInteger, ByRef rgAdvf As AdvF, <MarshalAs(UnmanagedType.LPArray)> ByRef rgFormatEtc() As FormatETC, ByRef lpAdviseSink As IOLE.IAdviseSink, <Out()> ByRef rgdwConnection As UInteger, ByRef pClientSite As IOLE.IOleClientSite, ByRef pStg As IOLE.IStorage, <Out(), MarshalAs(UnmanagedType.Interface)> ByRef ppvObj As Object) As <MarshalAs(UnmanagedType.Error)> Integer
        Public Declare Function OleCreateFontIndirect Lib "oleaut32.dll" (ByRef lpFontDesc As FontDesc, ByRef riid As Guid, <Out(), MarshalAs(UnmanagedType.Interface)> ByRef lplpvObj As Object) As <MarshalAs(UnmanagedType.Error)> Integer
        Public Declare Function OleCreateFromData Lib "ole32.dll" (ByRef pSrcDataObj As IOLE.IDataObject, ByRef riid As Guid, ByVal renderopt As OleRender, ByRef pFormatEtc As FormatETC, ByRef pClientSite As IOLE.IOleClientSite, ByRef pStg As OLE.IStorage, <Out(), MarshalAs(UnmanagedType.Interface)> ByRef ppvObj As Object) As <MarshalAs(UnmanagedType.Error)> Integer
        Public Declare Function OleCreateFromDataEx Lib "ole32.dll" (ByRef pSrcDataObj As IOLE.IDataObject, ByRef riid As Guid, ByVal dwFlags As UInteger, ByVal renderopt As OleRender, ByVal cFormats As UInteger, ByRef rgAdvf As AdvF, <MarshalAs(UnmanagedType.LPArray)> ByRef rgFormatEtc() As FormatETC, ByRef lpAdviseSink As IOLE.IAdviseSink, <Out()> ByRef rgdwConnection As UInteger, ByRef pClientSite As IOLE.IOleClientSite, ByRef pStg As IOLE.IStorage, <Out(), MarshalAs(UnmanagedType.Interface)> ByRef ppvObj As Object) As <MarshalAs(UnmanagedType.Error)> Integer
        Public Declare Function OleCreateFromFile Lib "ole32.dll" (ByRef rclsid As Guid, <MarshalAs(UnmanagedType.LPWStr)> ByVal lpszFileName As String, ByRef riid As Guid, ByVal renderopt As OleRender, ByRef lpFormatEtc As FormatETC, ByRef pClientSite As IOLE.IOleClientSite, ByRef pStg As IOLE.IStorage, <Out(), MarshalAs(UnmanagedType.Interface)> ByRef ppvObj As Object) As <MarshalAs(UnmanagedType.Error)> Integer
        Public Declare Function OleCreateFromFileEx Lib "ole32.dll" (ByRef rclsid As Guid, <MarshalAs(UnmanagedType.LPWStr)> ByVal lpszFileName As String, ByRef riid As Guid, ByVal dwFlags As UInteger, ByVal renderopt As OleRender, ByVal cFormats As UInteger, ByRef rgAdvf As AdvF, <MarshalAs(UnmanagedType.LPArray)> ByRef rgFormatEtc() As FormatETC, ByRef lpAdviseSink As IOLE.IAdviseSink, <Out()> ByRef rgdwConnection As UInteger, ByRef pClientSite As IOLE.IOleClientSite, ByRef pStg As IOLE.IStorage, <Out(), MarshalAs(UnmanagedType.Interface)> ByRef ppvObj As Object) As <MarshalAs(UnmanagedType.Error)> Integer
        Public Declare Function OleCreateLink Lib "ole32.dll" (ByRef pmkLinkSrc As ICOM.IMoniker, ByRef riid As Guid, ByVal renderopt As OleRender, ByRef lpFormatEtc As FormatETC, ByRef pClientSite As IOLE.IOleClientSite, ByRef pStg As IOLE.IStorage, <Out(), MarshalAs(UnmanagedType.Interface)> ByRef ppvObj As Object) As <MarshalAs(UnmanagedType.Error)> Integer
        Public Declare Function OleCreateLinkEx Lib "ole32.dll" (ByRef pmkLinkSrc As ICOM.IMoniker, ByRef riid As Guid, ByVal dwFlags As UInteger, ByVal renderopt As OleRender, ByVal cFormats As UInteger, ByRef rgAdvf As AdvF, <MarshalAs(UnmanagedType.LPArray)> ByRef rgFormatEtc() As FormatETC, ByRef lpAdviseSink As IOLE.IAdviseSink, <Out()> ByRef rgdwConnection As UInteger, ByRef pClientSite As IOLE.IOleClientSite, ByRef pStg As IOLE.IStorage, <Out(), MarshalAs(UnmanagedType.Interface)> ByRef ppvObj As Object) As <MarshalAs(UnmanagedType.Error)> Integer
        Public Declare Function OleCreateLinkFromData Lib "ole32.dll" (ByRef pSrcDataObj As IOLE.IDataObject, ByRef riid As Guid, ByVal renderopt As OleRender, ByRef pFormatEtc As FormatETC, ByVal pClientSite As IOLE.IOleClientSite, ByRef pStg As IOLE.IStorage, <Out(), MarshalAs(UnmanagedType.Interface)> ByRef ppvObj As Object) As <MarshalAs(UnmanagedType.Error)> Integer
        Public Declare Function OleCreateLinkFromDataEx Lib "ole32.dll" (ByRef pSrcDataObj As IOLE.IDataObject, ByRef riid As Guid, ByVal dwFlags As UInteger, ByVal renderopt As OleRender, ByVal cFormats As UInteger, ByRef rgAdvf As AdvF, <MarshalAs(UnmanagedType.LPArray)> ByRef rgFormatEtc() As FormatETC, ByRef lpAdviseSink As IOLE.IAdviseSink, ByRef rgdwConnection As UInteger, ByRef pClientSite As IOLE.IOleClientSite, ByRef pStg As OLE.IStorage, <Out(), MarshalAs(UnmanagedType.Interface)> ByRef ppvObj As Object) As <MarshalAs(UnmanagedType.Error)> Integer
        Public Declare Function OleCreateLinkToFile Lib "ole32.dll" (<MarshalAs(UnmanagedType.LPWStr)> ByRef lpszFileName As String, ByRef riid As Guid, ByVal renderopt As OleRender, ByRef lpFormatEtc As FormatETC, ByRef pClientSite As IOLE.IOleClientSite, ByRef pStg As IOLE.IStorage, <Out(), MarshalAs(UnmanagedType.Interface)> ByRef ppvObj As Object) As <MarshalAs(UnmanagedType.Error)> Integer
        Public Declare Function OleCreateLinkToFileEx Lib "ole32.dll" (<MarshalAs(UnmanagedType.LPWStr)> ByRef lpszFileName As String, ByRef riid As Guid, ByVal dwFlags As UInteger, ByVal renderopt As OleRender, ByVal cFormats As UInteger, ByRef rgAdvf As AdvF, <MarshalAs(UnmanagedType.LPArray)> ByRef rgFormatEtc() As FormatETC, ByRef lpAdviseSink As OLE.IAdviseSink, <Out()> ByRef rgdwConnection As UInteger, ByRef pClientSite As IOLE.IOleClientSite, ByRef pStg As IOLE.IStorage, <Out(), MarshalAs(UnmanagedType.Interface)> ByRef ppvObj As Object) As <MarshalAs(UnmanagedType.Error)> Integer
        Public Declare Function OleCreateMenuDescriptor Lib "ole32.dll" (ByVal hMenuCombined As IntPtr, <MarshalAs(UnmanagedType.LPArray, SizeConst:=6)> ByRef lpMenuWidths() As UInteger) As IntPtr
        Public Declare Function OleCreatePictureIndirect Lib "oleaut32.dll" (ByRef lpPictDesc As PicDesc, ByRef riid As Guid, <MarshalAs(UnmanagedType.Bool)> ByVal fOwn As Boolean, <Out(), MarshalAs(UnmanagedType.Interface)> ByRef lplpvObj As Object) As <MarshalAs(UnmanagedType.Error)> Integer
        Public Declare Function OleCreateStaticFromData Lib "ole32.dll" (ByRef pSrcDataObj As IOLE.IDataObject, ByRef iid As Guid, ByVal renderopt As OleRender, ByRef pFormatEtc As FormatETC, ByRef pClientSite As IOLE.IOleClientSite, ByRef pStg As IOLE.IStorage, <Out(), MarshalAs(UnmanagedType.Interface)> ByRef ppvObj As Object) As <MarshalAs(UnmanagedType.Error)> Integer
        Public Declare Sub OleDestroyMenuDescriptor Lib "ole32.dll" (ByVal hOleMenu As IntPtr)
        Public Declare Function OleDraw Lib "ole32.dll" (<MarshalAs(UnmanagedType.IUnknown)> ByRef pUnknown As Object, ByVal dwAspect As DVAspect, ByVal hdcDraw As IntPtr, ByRef lprcBounds As Rect) As <MarshalAs(UnmanagedType.Error)> Integer
        Public Declare Function OleDuplicateData Lib "ole32.dll" (ByVal hSrc As IntPtr, ByVal cfFormat As ClipFormat, ByVal uiFlags As UInteger) As IntPtr
        Public Declare Function OleFlushClipboard Lib "ole32.dll" () As <MarshalAs(UnmanagedType.Error)> Integer
        Public Declare Function OleGetClipboard Lib "ole32.dll" (<Out()> ByRef ppDataObj As IOLE.IDataObject) As <MarshalAs(UnmanagedType.Error)> Integer
        Public Declare Function OleInitialize Lib "ole32.dll" (ByVal pvReserved As UInteger) As <MarshalAs(UnmanagedType.Error)> Integer
        Public Declare Function OleIsCurrentClipboard Lib "ole32.dll" (ByRef pDataObj As IOLE.IDataObject) As <MarshalAs(UnmanagedType.Error)> Integer
        Public Declare Function OleIsRunning Lib "ole32.dll" (ByRef pObject As IOLE.IOleObject) As <MarshalAs(UnmanagedType.Bool)> Boolean
        Public Declare Function OleLoad Lib "ole32.dll" (ByRef pStg As IOLE.IStorage, ByRef riid As Guid, ByRef pClientSite As IOLE.IOleClientSite, <Out(), MarshalAs(UnmanagedType.Interface)> ByRef ppvObj As Object) As <MarshalAs(UnmanagedType.Error)> Integer
        Public Declare Function OleLoadFromStream Lib "ole32.dll" (ByRef pStm As IOLE.IStream, ByRef iidInterface As Guid, <Out(), MarshalAs(UnmanagedType.Interface)> ByRef ppvObj As Object) As <MarshalAs(UnmanagedType.Error)> Integer
        Public Declare Function OleLoadPicture Lib "oleaut32.dll" (ByRef lpstream As IOLE.IStream, ByVal lSize As Integer, <MarshalAs(UnmanagedType.Bool)> ByVal fRunmode As Boolean, ByRef riid As Guid, <Out(), MarshalAs(UnmanagedType.Interface)> ByRef lplpvObj As Object) As <MarshalAs(UnmanagedType.Error)> Integer
        Public Declare Function OleLoadPictureEx Lib "oleaut32.dll" (ByRef lpstream As IOLE.IStream, ByVal lSize As Integer, <MarshalAs(UnmanagedType.Bool)> ByVal fRunmode As Boolean, ByRef riid As Guid, ByVal xSizeDesired As UInteger, ByVal ySizeDesired As UInteger, ByVal dwFlags As UInteger, <Out(), MarshalAs(UnmanagedType.Interface)> ByRef lplpvObj As Object) As <MarshalAs(UnmanagedType.Error)> Integer
        Public Declare Function OleLockRunning Lib "ole32.dll" (<MarshalAs(UnmanagedType.IUnknown)> ByRef pUnknown As Object, <MarshalAs(UnmanagedType.Bool)> ByVal fLock As Boolean, <MarshalAs(UnmanagedType.Bool)> ByVal fLastUnlockCloses As Boolean) As <MarshalAs(UnmanagedType.Error)> Integer
        Public Declare Function OleMetafilePictFromIconAndLabel Lib "ole32.dll" (ByVal hIcon As IntPtr, <MarshalAs(UnmanagedType.LPWStr)> ByVal lpszLabel As String, <MarshalAs(UnmanagedType.LPWStr)> ByVal lpszSourceFile As String, ByVal iIconIndex As UInteger) As IntPtr
        Public Declare Function OleNoteObjectVisible Lib "ole32.dll" (<MarshalAs(UnmanagedType.IUnknown)> ByRef pUnknown As Object, <MarshalAs(UnmanagedType.Bool)> ByVal fVisible As Boolean) As <MarshalAs(UnmanagedType.Error)> Integer
        Public Declare Function OleQueryCreateFromData Lib "ole32.dll" (ByRef pSrcDataObject As IOLE.IDataObject) As <MarshalAs(UnmanagedType.Error)> Integer
        Public Declare Function OleQueryLinkFromData Lib "ole32.dll" (ByRef pSrcDataObject As IOLE.IDataObject) As <MarshalAs(UnmanagedType.Error)> Integer
        Public Declare Function OleRegEnumFormatEtc Lib "ole32.dll" (ByRef clsid As Guid, ByVal dwDirection As DataDir, <Out()> ByRef ppenum As IOLE.IEnumFORMATETC) As <MarshalAs(UnmanagedType.Error)> Integer
        Public Declare Function OleRegEnumVerbs Lib "ole32.dll" (ByRef clsid As Guid, <Out()> ByVal ppenum As IOLE.IEnumOLEVERB) As <MarshalAs(UnmanagedType.Error)> Integer
        Public Declare Function OleRun Lib "ole32.dll" (<MarshalAs(UnmanagedType.IUnknown)> ByRef pUnknown As Object) As <MarshalAs(UnmanagedType.Error)> Integer
        Public Declare Function OleSave Lib "ole32.dll" (ByRef pPS As ICOM.IPersistStorage, ByRef pStg As IOLE.IStorage, <MarshalAs(UnmanagedType.Bool)> ByVal fSameAsLoad As Boolean) As <MarshalAs(UnmanagedType.Error)> Integer
        Public Declare Function OleSaveToStream Lib "ole32.dll" (ByRef pPStm As ICOM.IPersistStream, ByRef pStm As IOLE.IStream) As <MarshalAs(UnmanagedType.Error)> Integer
        Public Declare Function OleSetClipboard Lib "ole32.dll" (ByRef pDataObj As IOLE.IDataObject) As <MarshalAs(UnmanagedType.Error)> Integer
        Public Declare Function OleSetContainedObject Lib "ole32.dll" (<MarshalAs(UnmanagedType.IUnknown)> ByRef pUnknown As Object, <MarshalAs(UnmanagedType.Bool)> ByVal fContained As Boolean) As <MarshalAs(UnmanagedType.Error)> Integer
        Public Declare Function OleSetMenuDescriptor Lib "ole32.dll" (ByRef hOleMenu As IntPtr, ByVal hwndFrame As IntPtr, ByVal hwndActiveObject As IntPtr, ByRef lpFrame As IOLE.IOleInPlaceFrame, ByRef lpActiveObj As IOLE.IOleInPlaceActiveObject) As <MarshalAs(UnmanagedType.Error)> Integer
        Public Declare Function OleTranslateAccelerator Lib "ole32.dll" (ByRef lpFrame As IOLE.IOleInPlaceFrame, ByRef lpFrameInfo As OleInPlaceFrameInfo, ByRef lpmsg As Msg) As <MarshalAs(UnmanagedType.Error)> Integer
        Public Declare Function OleUIAddVerbMenu Lib "oledlg.dll" Alias "OleUIAddVerbMenuA" (ByRef lpOleObj As IOLE.IOleObject, <MarshalAs(UnmanagedType.LPTStr)> ByVal lpszShortType As String, ByVal hMenu As IntPtr, ByVal uPos As UInteger, ByVal uIDVerbMin As UInteger, ByVal uIDVerbMax As UInteger, <MarshalAs(UnmanagedType.Bool)> ByVal bAddConvert As Boolean, ByVal idConvert As UInteger, <Out()> ByRef lphMenu As IntPtr) As <MarshalAs(UnmanagedType.Bool)> Boolean
        Public Declare Function OleUIBusyA Lib "oledlg.dll" (ByRef TLPOLEUIBUSYA As OleUIBusyA) As UInteger
        Public Declare Function OleUIBusyW Lib "oledlg.dll" (ByRef TLPOLEUIBUSYW As OleUIBusyW) As UInteger
        Public Declare Function OleUICanConvertOrActivateAs Lib "oledlg.dll" (ByRef rClsid As Guid, <MarshalAs(UnmanagedType.Bool)> ByVal fIsLinkedObject As Boolean, ByVal wFormat As UShort) As <MarshalAs(UnmanagedType.Bool)> Boolean
        Public Declare Function OleUIChangeIconA Lib "oledlg.dll" (ByRef TLPOLEUICHANGEICONA As OleUIChangeIconA) As UInteger
        Public Declare Function OleUIChangeIconW Lib "oledlg.dll" (ByRef TLPOLEUICHANGEICONW As OleUIChangeIconW) As UInteger
        Public Declare Function OleUIChangeSourceA Lib "oledlg.dll" (ByRef TLPOLEUICHANGESOURCEA As OleUIChangeSourceA) As UInteger
        Public Declare Function OleUIChangeSourceW Lib "oledlg.dll" (ByRef TLPOLEUICHANGESOURCEW As OleUIChangeSourceW) As UInteger
        Public Declare Function OleUIConvertA Lib "oledlg.dll" (ByRef TLPOLEUICONVERTA As OleUIConvertA) As UInteger
        Public Declare Function OleUIConvertW Lib "oledlg.dll" (ByRef TLPOLEUICONVERTW As OleUIConvertW) As UInteger
        Public Declare Function OleUIEditLinksA Lib "oledlg.dll" (ByRef TLPOLEUIEDITLINKSA As OleUIEditLinksA) As UInteger
        Public Declare Function OleUIEditLinksW Lib "oledlg.dll" (ByRef TLPOLEUIEDITLINKSW As OleUIEditLinksW) As UInteger
        Public Declare Function OleUIInsertObjectA Lib "oledlg.dll" (ByRef TLPOLEUIINSERTOBJECTA As OleUIInsertObjectA) As UInteger
        Public Declare Function OleUIInsertObjectW Lib "oledlg.dll" (ByRef TLPOLEUIINSERTOBJECTW As OleUIInsertObjectW) As UInteger
        Public Declare Function OleUIObjectPropertiesA Lib "oledlg.dll" (ByRef TLPOLEUIOBJECTPROPSA As OleUIObjectProps) As UInteger
        Public Declare Function OleUIObjectPropertiesW Lib "oledlg.dll" (ByRef TLPOLEUIOBJECTPROPSW As OleUIObjectProps) As UInteger
        Public Declare Function OleUIPasteSpecialA Lib "oledlg.dll" (ByRef TLPOLEUIPASTESPECIALA As OleUIPasteSpecialA) As UInteger
        Public Declare Function OleUIPasteSpecialW Lib "oledlg.dll" (ByRef TLPOLEUIPASTESPECIALW As OleUIPasteSpecialW) As UInteger
        Public Declare Function OleUIPromptUser Lib "oledlg.dll" Alias "OleUIPromptUserA" (ByVal nTemplate As Integer, ByVal hwndParent As IntPtr, ByVal ParamArray OptionalArguments() As String) As Integer
        Public Declare Function OleUIUpdateLinksA Lib "oledlg.dll" (ByRef lpOleUILinkCntr As IOLE.IOleUILinkContainer, ByVal hwndParent As IntPtr, <MarshalAs(UnmanagedType.LPStr)> ByVal lpszTitle As String, ByVal cLinks As Integer) As <MarshalAs(UnmanagedType.Bool)> Boolean
        Public Declare Function OleUIUpdateLinksW Lib "oledlg.dll" (ByRef lpOleUILinkCntr As IOLE.IOleUILinkContainer, ByVal hwndParent As IntPtr, <MarshalAs(UnmanagedType.LPWStr)> ByVal lpszTitle As String, ByVal cLinks As Integer) As <MarshalAs(UnmanagedType.Bool)> Boolean
        Public Declare Function OleUninitialize Lib "ole32.dll" () As <MarshalAs(UnmanagedType.Error)> Integer
        Public Declare Function RegisterDragDrop Lib "ole32.dll" (ByRef hwnd As IntPtr, ByRef pDropTarget As IOLE.IDropTarget) As <MarshalAs(UnmanagedType.Error)> Integer
        Public Declare Sub ReleaseStgMedium Lib "ole32.dll" (ByRef lpstgmedium As StgMedium)
        Public Declare Function RevokeDragDrop Lib "ole32.dll" (ByVal hwnd As IntPtr) As <MarshalAs(UnmanagedType.Error)> Integer

        ' OLE Controls and Propperty Pages API
        Public Declare Function OleCreatePropertyFrame Lib "oleaut32.dll" (ByVal hwndOwner As IntPtr, ByVal x As UInteger, ByVal y As UInteger, <MarshalAs(UnmanagedType.LPWStr)> ByVal lpszCaption As String, ByVal cObjects As UInteger, <MarshalAs(UnmanagedType.LPArray, ArraySubType:=UnmanagedType.IUnknown)> ByRef ppUnk() As Object, ByVal cPages As UInteger, <MarshalAs(UnmanagedType.LPArray)> ByRef pPageClsID() As Guid, ByVal lcid As Integer, ByVal dwReserved As UInteger, ByVal pvReserved As IntPtr) As <MarshalAs(UnmanagedType.Error)> Integer
        Public Declare Function OleCreatePropertyFrameIndirect Lib "oleaut32.dll" (ByRef lpParams As OCPFIParams) As <MarshalAs(UnmanagedType.Error)> Integer
        Public Declare Function OleLoadPicturePath Lib "oleaut32.dll" (<MarshalAs(UnmanagedType.LPWStr)> ByVal szURLorPath As String, <MarshalAs(UnmanagedType.IUnknown)> ByRef punkCaller As Object, ByVal dwReserved As UInteger, ByVal clrReserved As Integer, ByRef riid As Guid, <Out(), MarshalAs(UnmanagedType.Interface)> ByRef ppvRet As Object) As <MarshalAs(UnmanagedType.Error)> Integer
        Public Declare Function OleTranslateColor Lib "oleaut32.dll" (ByVal lOleColor As Integer, ByVal lHPalette As IntPtr, <Out()> ByRef lColorRef As Integer) As <MarshalAs(UnmanagedType.Error)> Integer

        ' OLE Automation API
        Public Declare Function LHashValOfName Lib "oleaut32.dll" () As UInteger
        Public Declare Function LHashValOfNameSys Lib "oleaut32.dll" (ByVal syskind As SysKind, ByVal lcid As Integer, <MarshalAs(UnmanagedType.LPWStr)> ByVal szName As String) As UInteger
        Public Declare Function LHashValOfNameSysA Lib "oleaut32.dll" (ByVal syskind As SysKind, ByVal lcid As Integer, <MarshalAs(UnmanagedType.LPStr)> ByVal szName As String) As UInteger
        Public Declare Function LoadTypeLib Lib "oleaut32.dll" (<MarshalAs(UnmanagedType.LPWStr)> ByRef TLpszModule As String, <Out()> ByRef ppTypeLib As IOLE.ITypeLib) As <MarshalAs(UnmanagedType.Error)> Integer
        Public Declare Function LoadTypeLibEx Lib "oleaut32.dll" (<MarshalAs(UnmanagedType.LPWStr)> ByRef TLpszModule As String, ByVal regkind As RegKind, <Out()> ByRef ppTypeLib As IOLE.ITypeLib) As <MarshalAs(UnmanagedType.Error)> Integer
        Public Declare Function LoadRegTypeLib Lib "oleaut32.dll" (ByRef rguid As Guid, ByVal wVerMajor As UShort, ByVal wVerMinor As UShort, ByVal lcid As Integer, <Out()> ByRef pptlib As IOLE.ITypeLib) As <MarshalAs(UnmanagedType.Error)> Integer
        Public Declare Function RegisterTypeLib Lib "oleaut32.dll" (ByRef ptlib As IOLE.ITypeLib, <MarshalAs(UnmanagedType.LPWStr)> ByRef szFullPath As String, <MarshalAs(UnmanagedType.LPWStr)> ByRef szHelpDir As String) As <MarshalAs(UnmanagedType.Error)> Integer
        Public Declare Function RegisterTypeLibForUser Lib "oleaut32.dll" (ByRef ptlib As IOLE.ITypeLib, <MarshalAs(UnmanagedType.LPWStr)> ByRef szFullPath As String, <MarshalAs(UnmanagedType.LPWStr)> ByRef szHelpDir As String) As <MarshalAs(UnmanagedType.Error)> Integer
        Public Declare Function UnRegisterTypeLib Lib "oleaut32.dll" (ByRef libID As Guid, ByVal wVerMajor As UShort, ByVal wVerMinor As UShort, ByVal lcid As Integer, ByVal syskind As SysKind) As <MarshalAs(UnmanagedType.Error)> Integer
        Public Declare Function UnRegisterTypeLibForUser Lib "oleaut32.dll" (ByRef libID As Guid, ByVal wVerMajor As UShort, ByVal wVerMinor As UShort, ByVal lcid As Integer, ByVal syskind As SysKind) As <MarshalAs(UnmanagedType.Error)> Integer
        Public Declare Function QueryPathOfRegTypeLib Lib "oleaut32.dll" (ByRef guid As Guid, ByVal wMaj As UShort, ByVal wMin As UShort, ByVal lcid As Integer, <MarshalAs(UnmanagedType.BStr)> ByRef lpbstrPathName As String) As <MarshalAs(UnmanagedType.Error)> Integer
        Public Declare Sub OaEnablePerUserTLibRegistration Lib "oleaut32.dll" ()

        Public Declare Function CreateTypeLib Lib "oleaut32.dll" (ByVal syskind As SysKind, <MarshalAs(UnmanagedType.LPWStr)> ByRef szFile As String, <Out()> ByRef ppctlib As OLE.ICreateTypeLib) As <MarshalAs(UnmanagedType.Error)> Integer
        Public Declare Function CreateTypeLib2 Lib "oleaut32.dll" (ByVal syskind As SysKind, <MarshalAs(UnmanagedType.LPWStr)> ByRef szFile As String, <Out()> ByRef ppctlib As OLE.ICreateTypeLib2) As <MarshalAs(UnmanagedType.Error)> Integer
        Public Declare Function OaBuildVersion Lib "oleaut32.dll" () As UInteger
        Public Declare Function OaCreateTypeLib2 Lib "oleaut32.dll" (ByVal syskind As SysKind, <MarshalAs(UnmanagedType.LPWStr)> ByRef szFile As String, <Out()> ByRef ppctlib As OLE.ICreateTypeLib2) As <MarshalAs(UnmanagedType.Error)> Integer

        Public Declare Function CreateErrorInfo Lib "ole32.dll" (<Out()> ByRef pperrinfo As OLE.ICreateErrorInfo) As <MarshalAs(UnmanagedType.Error)> Integer
        Public Declare Function GetErrorInfo Lib "ole32.dll" (ByVal dwReserved As UInteger, <Out()> ByRef pperrinfo As IOLE.IErrorInfo) As <MarshalAs(UnmanagedType.Error)> Integer
        Public Declare Function SetErrorInfo Lib "ole32.dll" (ByVal dwReserved As Int32, <Out()> ByRef perrinfo As IOLE.IErrorInfo) As <MarshalAs(UnmanagedType.Error)> Integer

        Public Declare Function CreateILockBytesOnHGlobal Lib "ole32.dll" (ByVal hGlobal As IntPtr, <MarshalAs(UnmanagedType.Bool)> ByVal fDeleteOnRelease As Boolean, <Out()> ByRef pplkbyt As IOLE.ILockBytes) As <MarshalAs(UnmanagedType.Error)> Integer
        Public Declare Function CreateStreamOnHGlobal Lib "ole32.dll" (ByVal hGlobal As IntPtr, <MarshalAs(UnmanagedType.Bool)> ByVal fDeleteOnRelease As Boolean, <Out()> ByRef ppstm As IOLE.IStream) As <MarshalAs(UnmanagedType.Error)> Integer
        Public Declare Function FmtIdToPropStgName Lib "ole32.dll" (ByRef pfmtid As Guid, <Out(), MarshalAs(UnmanagedType.LPWStr)> ByRef oszName As String) As <MarshalAs(UnmanagedType.Error)> Integer
        Public Declare Function FreePropVariantArray Lib "ole32.dll" (ByVal cVariants As UInteger, <MarshalAs(UnmanagedType.LPArray)> ByRef rgvars() As PropVariant) As <MarshalAs(UnmanagedType.Error)> Integer
        Public Declare Function GetConvertStg Lib "ole32.dll" (ByRef pStg As IOLE.IStorage) As <MarshalAs(UnmanagedType.Error)> Integer
        Public Declare Function GetHGlobalFromILockBytes Lib "ole32.dll" (ByRef plkbyt As IOLE.ILockBytes, <Out()> ByRef phglobal As IntPtr) As <MarshalAs(UnmanagedType.Error)> Integer
        Public Declare Function GetHGlobalFromStream Lib "ole32.dll" (ByRef pstm As IOLE.IStream, <Out()> ByRef phglobal As IntPtr) As <MarshalAs(UnmanagedType.Error)> Integer
        Public Declare Function OleConvertIStorageToOLESTREAM Lib "ole32.dll" (ByRef pstg As IOLE.IStorage, <Out()> ByRef lpolestream As IntPtr) As <MarshalAs(UnmanagedType.Error)> Integer
        Public Declare Function OleConvertIStorageToOLESTREAMEx Lib "ole32.dll" (ByRef pstg As IOLE.IStorage, ByVal cfFormat As ClipFormat, ByVal lWidth As Integer, ByVal lHeight As Integer, ByVal dwSize As UInteger, ByVal pmedium As StgMedium, <Out()> ByRef polestm As IntPtr) As <MarshalAs(UnmanagedType.Error)> Integer
        Public Declare Function OleConvertOLESTREAMToIStorage Lib "ole32.dll" (ByRef lpolestream As IntPtr, <Out()> ByRef pstg As IOLE.IStorage, ByRef ptd As DVTargetDevice) As <MarshalAs(UnmanagedType.Error)> Integer
        Public Declare Function OleConvertOLESTREAMToIStorageEx Lib "ole32.dll" (ByRef polestm As IntPtr, <Out()> ByRef pstg As IOLE.IStorage, <Out()> ByRef pcfFormat As ClipFormat, <Out()> ByRef plwWidth As Integer, <Out()> ByRef plHeight As Integer, <Out()> ByRef pdwSize As UInteger, <Out()> ByRef pmedium As StgMedium) As <MarshalAs(UnmanagedType.Error)> Integer
        Public Declare Function PropStgNameToFmtId Lib "ole32.dll" (<MarshalAs(UnmanagedType.LPWStr)> ByRef oszName As String, <Out()> ByRef pfmtid As Guid) As <MarshalAs(UnmanagedType.Error)> Integer
        Public Declare Function PropVariantClear Lib "ole32.dll" (ByRef pvar As PropVariant) As <MarshalAs(UnmanagedType.Error)> Integer
        Public Declare Function PropVariantCopy Lib "ole32.dll" (ByRef pvarDest As PropVariant, ByRef pvarSrc As PropVariant) As <MarshalAs(UnmanagedType.Error)> Integer
        Public Declare Sub PropVariantInit Lib "ole32.dll" (<Out()> ByRef pvar As PropVariant)
        Public Declare Function ReadClassStg Lib "ole32.dll" (ByRef pStg As IOLE.IStorage, <Out()> ByRef pclsid As Guid) As <MarshalAs(UnmanagedType.Error)> Integer
        Public Declare Function ReadClassStm Lib "ole32.dll" (ByRef pStm As IOLE.IStream, <Out()> ByRef pclsid As Guid) As <MarshalAs(UnmanagedType.Error)> Integer
        Public Declare Function ReadFmtUserTypeStg Lib "ole32.dll" (ByRef pstg As IOLE.IStorage, <Out()> ByRef pcf As ClipFormat, <Out(), MarshalAs(UnmanagedType.LPWStr)> ByRef lplpszUserType As String) As <MarshalAs(UnmanagedType.Error)> Integer
        Public Declare Function StgConvertPropertyToVariant Lib "ole32.dll" (ByRef prop As SerializedPropertyValue, ByVal CodePage As UShort, <Out()> ByRef pvar As PropVariant, ByRef pma As IOLE.IMemoryAllocator) As <MarshalAs(UnmanagedType.Bool)> Boolean
        Public Declare Function SetConvertStg Lib "ole32.dll" (ByRef pStg As IOLE.IStorage, <MarshalAs(UnmanagedType.Bool)> ByVal fConvert As Boolean) As <MarshalAs(UnmanagedType.Error)> Integer
        Public Declare Function StgConvertVariantToProperty Lib "ole32.dll" (ByRef pvar As PropVariant, ByVal CodePage As UShort, ByRef pprop As SerializedPropertyValue, ByRef pcb As UInteger, ByVal pid As UInteger, <MarshalAs(UnmanagedType.Bool)> ByVal fReserved As Boolean, <Out()> ByRef pcIndirect As UInteger) As SerializedPropertyValue
        Public Declare Function StgCreateDocfile Lib "ole32.dll" (<MarshalAs(UnmanagedType.LPWStr)> ByRef pwcsName As String, ByVal grfMode As UInteger, ByVal reserved As UInteger, <Out()> ByRef ppstgOpen As IOLE.IStorage) As <MarshalAs(UnmanagedType.Error)> Integer
        Public Declare Function StgCreateDocfileOnILockBytes Lib "ole32.dll" (ByRef plkbyt As IOLE.ILockBytes, ByVal grfMode As UInteger, ByVal reserved As UInteger, <Out()> ByRef ppstgOpen As IOLE.IStorage) As <MarshalAs(UnmanagedType.Error)> Integer
        Public Declare Function StgCreatePropSetStg Lib "ole32.dll" (ByRef pStorage As IOLE.IStorage, ByVal dwReserved As UInteger, <Out()> ByRef ppPropSetStg As IOLE.IPropertySetStorage) As <MarshalAs(UnmanagedType.Error)> Integer
        Public Declare Function StgCreatePropStg Lib "ole32.dll" (<MarshalAs(UnmanagedType.IUnknown)> ByRef pUnk As Object, ByRef fmtid As Guid, ByRef pclsid As Guid, ByVal grfFlags As PropSetFlags, ByVal dwReserved As UInteger, <Out()> ByRef ppPropStg As IOLE.IPropertyStorage) As <MarshalAs(UnmanagedType.Error)> Integer
        Public Declare Function StgCreateStorageEx Lib "ole32.dll" (<MarshalAs(UnmanagedType.LPWStr)> ByRef pwcsName As String, ByVal grfMode As UInteger, ByVal stgfmt As StgFmt, ByVal grfAttrs As UInteger, ByRef pStgOptions As StgOptions, ByRef pSecurityDescriptor As SecurityDescriptor, ByRef riid As Guid, <Out(), MarshalAs(UnmanagedType.Interface)> ByRef ppObjectOpen As Object) As <MarshalAs(UnmanagedType.Error)> Integer
        Public Declare Function StgDeserializePropVariant Lib "ole32.dll" (ByVal pprop As SerializedPropertyValue, ByVal cbMax As UInteger, <Out()> ByRef pvar As PropVariant) As <MarshalAs(UnmanagedType.Error)> Integer
        Public Declare Function StgGetIFillLockBytesOnFile Lib "ole32.dll" (<MarshalAs(UnmanagedType.LPWStr)> ByRef pwcsName As String, <Out()> ByRef ppflb As IOLE.IFillLockBytes) As <MarshalAs(UnmanagedType.Error)> Integer
        Public Declare Function StgGetIFillLockBytesOnILockBytes Lib "ole32.dll" (ByRef pilb As IOLE.ILockBytes, <Out()> ByRef ppflb As IOLE.IFillLockBytes) As <MarshalAs(UnmanagedType.Error)> Integer
        Public Declare Function StgIsStorageFile Lib "ole32.dll" (<MarshalAs(UnmanagedType.LPWStr)> ByRef pwcsName As String) As <MarshalAs(UnmanagedType.Error)> Integer
        Public Declare Function StgIsStorageILockBytes Lib "ole32.dll" (ByRef plkbyt As IOLE.ILockBytes) As <MarshalAs(UnmanagedType.Error)> Integer
        Public Declare Function StgOpenAsyncDocfileOnIFillLockBytes Lib "ole32.dll" (ByRef pflb As IOLE.IFillLockBytes, ByVal grfMode As UInteger, ByVal asyncFlags As UInteger, <Out()> ByRef ppstgOpen As OLE.IStorage) As <MarshalAs(UnmanagedType.Error)> Integer
        Public Declare Function StgOpenPropStg Lib "ole32.dll" (<MarshalAs(UnmanagedType.IUnknown)> ByRef pUnk As Object, ByRef fmtid As Guid, ByVal grfFlags As UInteger, ByVal dwReserved As UInteger, <Out()> ByRef ppPropStg As IOLE.IPropertyStorage) As <MarshalAs(UnmanagedType.Error)> Integer
        Public Declare Function StgOpenStorage Lib "ole32.dll" (<MarshalAs(UnmanagedType.LPWStr)> ByRef pwcsName As String, ByVal pstgPriority As IOLE.IStorage, ByVal grfMode As UInteger, <MarshalAs(UnmanagedType.LPWStr)> ByVal snbExclude As String, ByVal reserved As UInteger, <Out()> ByRef ppstgOpen As IOLE.IStorage) As <MarshalAs(UnmanagedType.Error)> Integer
        Public Declare Function StgOpenStorageEx Lib "ole32.dll" (<MarshalAs(UnmanagedType.LPWStr)> ByRef pwcsName As String, ByVal grfMode As UInteger, ByVal stgfmt As StgFmt, ByVal grfAttrs As UInteger, ByRef pStgOptions As StgOptions, ByVal reserved As IntPtr, ByRef riid As Guid, <Out(), MarshalAs(UnmanagedType.Interface)> ByRef ppObjectOpen As Object) As <MarshalAs(UnmanagedType.Error)> Integer
        Public Declare Function StgOpenStorageOnILockBytes Lib "ole32.dll" (ByRef plkbyt As IOLE.ILockBytes, ByRef pstgPriority As IOLE.IStorage, ByVal grfMode As UInteger, <MarshalAs(UnmanagedType.LPWStr)> ByVal snbExclude As String, ByVal reserved As UInteger, <Out()> ByRef ppstgOpen As IOLE.IStorage) As <MarshalAs(UnmanagedType.Error)> Integer
        Public Declare Function StgPropertyLengthAsVariant Lib "ole32.dll" (ByRef pProp As SerializedPropertyValue, ByVal cbProp As UInteger, ByVal CodePage As UShort, ByVal bReserved As Byte) As UInteger
        Public Declare Function StgSetTimes Lib "ole32.dll" (<MarshalAs(UnmanagedType.LPWStr)> ByRef lpszName As String, ByRef pctime As FileTime, ByRef patime As FileTime, ByRef pmtime As FileTime) As <MarshalAs(UnmanagedType.Error)> Integer
        Public Declare Function StgSerializePropVariant Lib "ole32.dll" (ByRef pVar As PropVariant, <Out()> ByRef ppProp As SerializedPropertyValue, <Out()> ByRef pcb As UInteger) As <MarshalAs(UnmanagedType.Error)> Integer
        Public Declare Function WriteClassStg Lib "ole32.dll" (ByRef pStg As IOLE.IStorage, ByRef rclsid As Guid) As <MarshalAs(UnmanagedType.Error)> Integer
        Public Declare Function WriteClassStm Lib "ole32.dll" (ByRef pStm As IOLE.IStream, ByRef rclsid As Guid) As <MarshalAs(UnmanagedType.Error)> Integer
        Public Declare Function WriteFmtUserTypeStg Lib "ole32.dll" (ByRef pstg As IOLE.IStorage, ByVal cf As ClipFormat, <MarshalAs(UnmanagedType.LPWStr)> ByVal lpszUserType As String) As <MarshalAs(UnmanagedType.Error)> Integer

    End Class

End Namespace